﻿<title>销售应用-发货</title>
<script src="/LiberUI/Scripts/jquery.js"></script>
<script src="/LiberUI/Scripts/LiberUI.Base.js"></script>
<link href="/SiteUI/Sale/share.css" rel="stylesheet" />
<link href="/SiteUI/Sale/Delivery.css" rel="stylesheet" />
<link href="/SiteUI/Sale/Orders.css" rel="stylesheet" />
<link href="/SiteUI/bootstrap-datepicker3.css" rel="stylesheet" />

<script>
    SoBiz.Template("_level2");
</script>

<body>

    <script type="text/html" section="ContentNavi" src="/Sale/_pvNaviLv2.html">

    </script>

    <script type="text/html" section="PageBody">
        <div class="col-lg-5 col-lg-offset-6 searchboxWraper">
            <!--搜索框组件容器-->
        </div>
        <div class="col-lg-10 col-lg-offset-1" id="Deliverys">
            <div class="row" id="lstDeliverys">
                <div class="col-lg-12 head">
                    <h4>发货单</h4>
                    <span class="cnd-status" status=''>全部</span>
                    <span class="cnd-status current" status="Active">未收货</span>
                    <span class="cnd-status" status='Completed'>已收货</span>
                    <span class="more-filter" id="more-filter">更多筛选条件</span>
                </div>
                <form class="col-lg-12 more-filter-box" id="more-filter-box">
                    <button class="more-filter-close" id="more-filter-close"><i class="soicon icon-highlightremove"></i></button>
                    <div class="filter-item">
                        <span class="label">采购方：</span>
                        <label class="input-box col-lg-12"><input class="input" type="text" name="client"></label>
                    </div>
                    <div class="filter-item">
                        <span class="label">发货人：</span>
                        <label class="input-box col-lg-12"><input class="input" type="text" name="sender"></label>
                    </div>
                    <div class="filter-item">
                        <span class="label">订货日期：</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="orderDateStart"></label>
                        <span class="col-lg-2">至</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="orderDateEnd"></label>
                    </div>
                    <div class="filter-item">
                        <span class="label">交货日期：</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="dlvDateStart"></label>
                        <span class="col-lg-2">至</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="dlvDateEnd"></label>
                    </div>
                    <div class="filter-item">
                        <span class="label">发货日期：</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="sendDateStart"></label>
                        <span class="col-lg-2">至</span>
                        <label class="input-box col-lg-5 date-picker"><input class="input" type="text" name="sendDateStart"></label>
                    </div>
                    <div class="filter-item">
                        <button class="filter-search">搜索</button>
                    </div>
                </form>
                <div class="col-lg-12" id="cnd-more">
                    <div class="row">

                    </div>
                </div>
                <div class="col-lg-12" id="dlv-lstDeliveries">

                </div>

                <div class="col-lg-12" id="sal-lstOrders-Paging"></div>
            </div>
        </div>
    </script>
    
    <!--发货用订单列表模板-->
    <script id="tplDeliveryItem" type="text/html">
        <div class="row noItem">
            <div class="col-lg-1 no-row-head">
                <img src='{{d.client_logo}}' />  <!--买方Logo-->
            </div>
            <div class="col-lg-11 no-row-body">
                <div class="row no-headline">
                    <div class="col-lg-4 no-tradeno">
                        <span>发货编号：</span><span>{{d.idstr}}</span>
                    </div>
                    <div class="col-lg-5 no-client">
                        <span><i class="soicon icon-004office"></i>&nbsp;{{(d.client_realname)?d.client_realname:d.invoiceheading}}</span>
                    </div>
                    <div class="col-lg-3">

                        <a class="LinkTo" target="_blank" href="/Trade/DeliveryBillDetail?oid={{d.idstr}}">查看详情>></a>
                    </div>
                </div>
                <div class="row no-describe">
                    <div class="col-lg-5">
                        <span>交易编号：</span><span>{{d.idstr}}</span>
                        <br />
                        <span>内部订单：</span><span>{{d.src_orderserial}}</span>
                        <br />
                        <span>销&nbsp;&nbsp;售&nbsp;&nbsp;员：</span><span>{{d.saler}}</span>
                        <br />
                    </div>
                    <div class="col-lg-4 withLeftIndent">
                        <span>发货日期：</span><span><strong>{{d.createtime}}</strong></span>
                        <br />
                        <span>收&nbsp;&nbsp;货&nbsp;&nbsp;人：</span><span>{{d.consignee}}</span>
                        <br />
                        <span>收货日期：</span>
                        <span>{{d.updatetime}}</span>
                        <br />
                    </div>
                    <div class="col-lg-3">

                    </div>
                </div>
            </div>
        </div>
    </script>
    <script src="/LiberUI/Scripts/moment.js"></script>
    <script src="/LiberUI/Scripts/bootstrap-datepicker.js"></script>
    <script src="/LiberUI/Scripts/laytpl.js"></script>
    <script>
    Delivery = {
        cnd: {
            status: "all",
            flag: null,
            dlvDate: null
        },
        tplDlvItem: null,
        lstDeliverys: null,
        Query: function (recount) {
          Delivery.lstDeliverys.vl(null)
                               .update()
                               .Loading("正在加载...");

          if (recount) {
              Delivery.cnd.page = 1;
              $.getJSON("/Sale/CountOrders", Delivery.cnd, Delivery.onCountEnd);
          }

          $.getJSON("/Sale/QueryDeliveries", Delivery.cnd, Delivery.onGetDeliveriesEnd);
        },
        onGetDeliveriesEnd:function(rtn){
            if (rtn.IsPositive) {
                Delivery.lstDeliverys.vl(rtn.Data["Deliveries"])
                                     .update()
                                     .show();
            }
        },
        makeDlvItemView: function ($li, obj) {
            obj.createtime=new Date(obj.createtime).toString();
            obj.updatetime =obj.status=='Completed'?new Date(obj.updatetime).toString():'-';
            var itm = $(Delivery.tplDlvItem.render(obj));
            SoBiz.CheckAuthor(obj,$li);
            $li.append(itm.addClass("fladeInUp"));
        },
        onCountEnd: function (rtn) {
            //根据统计结果添加计数标记
            if (rtn.IsPositive) {
                Delivery.paging.option("Total", rtn.Data.Total)
                                .option("CurrPage", 1)
                                .update();
            }
            else {
                $("#lstDeliverys>.head").find("em").remove();
            }
        },
        GoPage: function (pg) {
            Delivery.cnd.page = pg;
            Delivery.Query();
        },
        popCndDlvDate: null
    }
    SoBiz.Login(function () {
        SoBiz.Ready(function () {
            $(".Searcher").appendTo(".searchboxWraper").fadeIn();

            Delivery.cnd.flag = getUrlParam("flag");
            Delivery.cnd.status = getUrlParam("status") || "Active";


            Delivery.tplDlvItem = laytpl($("#tplDeliveryItem")[0].innerHTML);  //定义发货单列表项模板实例
            Delivery.lstDeliverys = new LiberUI.Lister("#dlv-lstDeliveries")
                                               .option("Slctble", false)
                                               .option("ContentRender", Delivery.makeDlvItemView);
            Delivery.paging = new LiberUI.Paging("#sal-lstOrders-Paging")
                .option("Row", 20)
                .option("BtnClick", Delivery.GoPage)
                .show();
            $("#lstDeliverys>.head").delegate(".cnd-status", "click", function (ev) {
                var status = $(ev.currentTarget).attr("status");
                var flag = $(ev.currentTarget).attr("flag");

                Delivery.cnd.status = status || "";
                Delivery.cnd.flag = flag || "";
                Delivery.Query();
                $("#lstDeliverys").find(".current").removeClass("current");
                $(ev.currentTarget).addClass("current");
            });

            Delivery.Query(true);

            /*  16/7/28 更多筛选条件 */
            function fillSubmitData(data) {
                Delivery.cnd.client = data.eq(0).val();
                Delivery.cnd.sender = data.eq(1).val();
                Delivery.cnd.orderDateStart = data.eq(2).val();
                Delivery.cnd.orderDateEnd = data.eq(3).val();
                Delivery.cnd.dlvDateStart = data.eq(4).val();
                Delivery.cnd.dlvDateEnd = data.eq(5).val();
                Delivery.cnd.sendDateStart = data.eq(6).val();
                Delivery.cnd.sendDateEnd = data.eq(7).val();
            }
            $('#more-filter-box .date-picker input').datepicker({
                autoclose: true,
                todayHighlight: true,
                format: 'yyyy-mm-dd'
            });
            $('#more-filter').on('click', function () {
                var status = $(this).hasClass('more-filter-open');
                if (status == true) {

                    //如果已经展开，触发关闭按钮效果
                    $('#more-filter-close').trigger('click');
                    return;
                }

                //获取原始高度
                var box = $('#more-filter-box'), boxHeight = box.css('height', 'auto').height();

                //恢复0高度以便动画进行
                box.css('height', '0');

                $(this).addClass('more-filter-open');
                $('#more-filter-box').stop().animate({ height: boxHeight + 20 }, 500); // 20为 more-filter-box padding
            });
            $('#more-filter-close').on('click', function (e) {
                e.preventDefault();
                $('#more-filter-box').stop().animate({ height: 0 }, 500);
                $('#more-filter').removeClass('more-filter-open');
                //清空输入项
                var inputs = $('#more-filter-box').find('input');
                inputs.val('');
                fillSubmitData(inputs);
            });
            $('#more-filter-box').on('submit', function (e) {
                e.preventDefault();
                //筛选条件提交
                fillSubmitData($(this).find('input'));
                Delivery.Query(true);
            });
        })
    })
    </script>

</body>

